package com.huawei.appgallery.forum.comments.ui;

import android.app.ActionBar;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.forum.base.card.bean.ImageInfo;
import com.huawei.appgallery.forum.base.card.bean.PostTime;
import com.huawei.appgallery.forum.base.card.bean.Reply;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.base.https.jgw.JGWTabDetailResponse;
import com.huawei.appgallery.forum.base.ui.ForumActivity;
import com.huawei.appgallery.forum.cards.bean.ForumTitleSortCardBean;
import com.huawei.appgallery.forum.comments.api.ICommentDetailProtocol;
import com.huawei.appgallery.forum.comments.api.ICommentDetailResult;
import com.huawei.appgallery.forum.comments.card.ForumCommentDetailHeadCardBean;
import com.huawei.appgallery.forum.comments.card.ForumReplyCardBean;
import com.huawei.appgallery.forum.option.api.IUpdateCommentActivityProtocol;
import com.huawei.appgallery.forum.option.api.IUpdateCommentActivityResult;
import com.huawei.appgallery.forum.option.reply.bean.ReplyResponse;
import com.huawei.appgallery.forum.posts.api.IPostDetailProtocol;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.hmf.annotation.ActivityDefine;
import huawei.widget.HwCounterTextLayout;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.bqx;
import o.bqy;
import o.brc;
import o.brd;
import o.brf;
import o.brj;
import o.bsd;
import o.bse;
import o.bsv;
import o.btb;
import o.bue;
import o.bue.a;
import o.bue.c;
import o.bue.h;
import o.bue.j;
import o.buj;
import o.buk;
import o.bul;
import o.bwx;
import o.bxv.d;
import o.byc;
import o.byg;
import o.byl;
import o.byt;
import o.byw;
import o.cbc;
import o.cbd;
import o.cbh;
import o.cgv;
import o.cvt;
import o.doo;
import o.epv;
import o.CollectCheck;
import o.ActivityUtil;
import o.evk;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjc;
import o.fjf;
import o.fjm;
import o.fjo;
import o.fjq;
import o.FragmentTransaction;
import o.ll;

@ActivityDefine(alias = "comment.detail.inner.activity", protocol = ICommentDetailProtocol.class, result = ICommentDetailResult.class)
public class CommentDetailActivity extends ForumActivity implements com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.e, OnClickListener, buk, buj {
    private int ʹ = -1;
    private int ʻˊ;
    private int ʻˋ = 1;
    private View ʻॱ;
    private int ʻᐝ = 0;
    private int ʼˊ;
    private boolean ʼˋ = false;
    private ImageView ʽॱ;
    private LinearLayout ʾ;
    private TextView ʿ;
    private EditText ˈ;
    private ForumCommentDetailHeadCardBean ˉ;
    private HwCounterTextLayout ˊˊ;
    private ProgressBar ˊˋ;
    private int ˊᐝ;
    private boolean ˋˊ = false;
    private PopupMenu ˋˋ;
    protected long ˋॱ;
    private String ˋᐝ;
    private String ˌ;
    private long ˍ;
    private boolean ˎˎ = false;
    private int ˎˏ;
    private User ˏˎ = null;
    private e ˏˏ;
    private IntentFilter ˑ;
    private CommentDetailFragment ͺ;
    private int ͺॱ = 1;
    private boolean ـ = false;
    private int ॱʻ = 0;
    private boolean ॱʼ = false;
    private long ॱʽ = 0;
    bwx ॱˊ;
    private String ॱˋ;
    private TextView ॱˎ;
    private boolean ॱͺ = false;
    private boolean ᐝˊ = false;
    private String ᐝˋ;
    private LinearLayout ᐝॱ;
    private FrameLayout ᐝᐝ;
    private int ᐧ = 0;
    private int ᐨ;
    private boolean ᶥ = false;
    private boolean ㆍ = false;
    private long ꓸ = 0;
    private boolean ꜞ = false;
    private int ꜟ = 0;
    private int ꞌ = -1;
    private boolean ﹳ = false;
    private int ﾞ = -1;
    private RelativeLayout ﾟ;

    class e extends BroadcastReceiver {
        final /* synthetic */ CommentDetailActivity ˊ;

        private e(CommentDetailActivity commentDetailActivity) {
            this.ˊ = commentDetailActivity;
        }

        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (TextUtils.isEmpty(action)) {
                bqx.ॱ("CommentDetailActivity", "action is empty");
                return;
            }
            Object obj = -1;
            switch (action.hashCode()) {
                case -1092543779:
                    if (action.equals("forum.comments.reply")) {
                        obj = 1;
                        break;
                    }
                    break;
                case -451060412:
                    if (action.equals("forum.comments.like")) {
                        obj = 3;
                        break;
                    }
                    break;
                case -199981512:
                    if (action.equals("forum.comments.list.refresh")) {
                        obj = null;
                        break;
                    }
                    break;
                case 89947160:
                    if (action.equals("forum.comments.delete")) {
                        obj = 2;
                        break;
                    }
                    break;
                case 764218603:
                    if (action.equals("forum.comments.list.refresh.all")) {
                        obj = 4;
                        break;
                    }
                    break;
            }
            switch (obj) {
                case null:
                    ˏ(intent);
                    return;
                case 1:
                    ॱ(intent);
                    return;
                case 2:
                    ˊ(intent);
                    return;
                case 3:
                    ˎ(intent);
                    return;
                case 4:
                    this.ˊ.ॱˊ();
                    return;
                default:
                    return;
            }
        }

        private void ˎ(Intent intent) {
            if (intent.getExtras() != null) {
                this.ˊ.ॱͺ = true;
                this.ˊ.ॱʼ = intent.getExtras().getBoolean("is_like");
                this.ˊ.ॱʽ = intent.getExtras().getLong("like_count");
            }
        }

        private void ˊ(Intent intent) {
            if (intent.getExtras() != null) {
                long longExtra = intent.getLongExtra("reply_id", -1);
                if (longExtra != -1) {
                    this.ˊ.ˏ(longExtra);
                }
            }
        }

        private void ॱ(Intent intent) {
            User user;
            if (intent.getExtras() == null) {
                user = null;
            } else {
                user = (User) intent.getExtras().get("from_user");
            }
            this.ˊ.ॱ(user);
        }

        private void ˏ(Intent intent) {
            if (intent.getExtras() != null) {
                int intExtra = intent.getIntExtra("notify_type", -1);
                if (intExtra != -1) {
                    this.ˊ.ˏ(intExtra);
                    this.ˊ.ˎ(0);
                }
            }
        }
    }

    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        cgv.ˋ(this, b.ॱ, b.ʼ);
        setContentView(a.ॱ);
        ͺ();
        ᐝॱ();
        ˋᐝ();
        ʼॱ();
    }

    private void ͺ() {
        this.ˏˏ = new e();
        this.ˑ = new IntentFilter();
        this.ˑ.addAction("forum.comments.list.refresh");
        this.ˑ.addAction("forum.comments.reply");
        this.ˑ.addAction("forum.comments.delete");
        this.ˑ.addAction("forum.comments.like");
        this.ˑ.addAction("forum.comments.list.refresh.all");
    }

    private void ᐝॱ() {
        ICommentDetailProtocol iCommentDetailProtocol = (ICommentDetailProtocol) this.ˏॱ.ॱ();
        this.ॱˋ = iCommentDetailProtocol.getUri();
        this.ˎˏ = iCommentDetailProtocol.getSourceType();
        this.ᐝˊ = iCommentDetailProtocol.getNeedComment();
        boolean clickReplyView = iCommentDetailProtocol.getClickReplyView();
        int errorCode = iCommentDetailProtocol.getErrorCode();
        this.ˊॱ = iCommentDetailProtocol.getDomainId();
        ـ();
        ˑ();
        fjb ˎ = fho.ˏ().ˋ("Comments").ˎ("comment.detail.inner.fragment");
        ICommentDetailProtocol iCommentDetailProtocol2 = (ICommentDetailProtocol) ˎ.ˊ();
        iCommentDetailProtocol2.setUri(this.ॱˋ);
        iCommentDetailProtocol2.setErrorCode(errorCode);
        iCommentDetailProtocol2.setDomainId(iCommentDetailProtocol.getDomainId());
        this.ͺ = (CommentDetailFragment) fjm.ˏ(fiu.ˊ().ˋ(this, ˎ)).ˏ();
        FragmentTransaction ˊ = ˏॱ().ˊ();
        ˊ.ˏ(o.bue.e.ˊ, this.ͺ);
        ˊ.ˏ();
        if (clickReplyView && this.ꓸ == 0) {
            this.ͺ.ˊॱ(1);
        }
        if (this.ꓸ != 0) {
            this.ﹳ = true;
        }
    }

    private void ʼॱ() {
        this.ᐝॱ = (LinearLayout) findViewById(o.bue.e.ˌ);
        azb.ˏ(this.ᐝॱ);
        this.ʿ = (TextView) findViewById(o.bue.e.ͺ);
        this.ʽॱ = (ImageView) findViewById(o.bue.e.ʽॱ);
        this.ˈ = (EditText) findViewById(o.bue.e.ʾ);
        this.ˈ.setLines(1);
        this.ˈ.addTextChangedListener(new TextWatcher(this) {
            final /* synthetic */ CommentDetailActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                this.ˏ.ˏ(charSequence);
            }

            public void afterTextChanged(Editable editable) {
                this.ˏ.ˋ(editable);
            }
        });
        this.ˈ.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener(this) {
            final /* synthetic */ CommentDetailActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void onGlobalLayout() {
                Rect rect = new Rect();
                this.ˏ.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
                int ॱ = epv.ॱ(this.ˏ);
                if (azb.ˎ(this.ˏ)) {
                    this.ˏ.ꞌ = ॱ - rect.bottom;
                } else {
                    this.ˏ.ʹ = ॱ - rect.bottom;
                }
                if (this.ˏ.ʻˋ > 1) {
                    new Handler().post(new Runnable(this) {
                        final /* synthetic */ AnonymousClass3 ˎ;

                        {
                            this.ˎ = r1;
                        }

                        public void run() {
                            if (this.ˎ.ˏ.ˈ != null) {
                                this.ˎ.ˏ.ˈ.setMaxHeight(this.ˎ.ˏ.ᐝˋ());
                            }
                        }
                    });
                }
            }
        });
        this.ˈ.setFocusable(false);
        this.ˈ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ CommentDetailActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void onClick(View view) {
                this.ˊ.ᐝ();
            }
        });
        this.ʾ = (LinearLayout) findViewById(o.bue.e.ˋˊ);
        this.ʾ.setOnClickListener(this);
        if (TextUtils.isEmpty(ˎˏ())) {
            this.ʾ.setClickable(false);
        } else {
            this.ʾ.setClickable(true);
        }
        this.ᐝॱ.setOnClickListener(this);
        this.ॱˊ = (bwx) fho.ˏ().ˋ("Operation").ॱ(bwx.class);
        this.ˊˊ = (HwCounterTextLayout) findViewById(o.bue.e.ˊˋ);
        this.ˊˋ = (ProgressBar) findViewById(o.bue.e.ˈ);
        this.ᐝᐝ = (FrameLayout) findViewById(o.bue.e.ʿ);
        azb.ˏ(this.ᐝᐝ);
        this.ˊˊ.setPaddingRelative(0, 0, 0, 0);
    }

    private void ˏ(CharSequence charSequence) {
        int lineCount = this.ˈ.getLineCount();
        if (this.ʻˋ != lineCount) {
            this.ʻˋ = lineCount;
            if (this.ʻˋ == 1) {
                this.ˈ.setLines(1);
                return;
            }
            this.ˈ.setMaxLines(this.ʻˋ);
            this.ˈ.setMaxHeight(ᐝˋ());
        }
    }

    public boolean ˋ(TaskFragment taskFragment, TaskFragment.b bVar) {
        if (!ActivityUtil.isAcitivtyNotValid(this) && bVar.ˋ.getResponseCode() == 0 && bVar.ˋ.getRtnCode_() == 0 && (bVar.ˋ instanceof JGWTabDetailResponse)) {
            JGWTabDetailResponse jGWTabDetailResponse = (JGWTabDetailResponse) bVar.ˋ;
            this.ˋॱ = jGWTabDetailResponse.ʻ();
            if (this.ㆍ) {
                ˊ(jGWTabDetailResponse);
            } else {
                ˏ(jGWTabDetailResponse);
                ˊᐝ();
                this.ㆍ = true;
            }
        }
        return false;
    }

    private void ˏ(JGWTabDetailResponse jGWTabDetailResponse) {
        List<LayoutData> ᐝॱ = jGWTabDetailResponse.ᐝॱ();
        if (ᐝॱ != null && ᐝॱ.size() > 0) {
            for (LayoutData layoutData : ᐝॱ) {
                if (ForumCommentDetailHeadCardBean.NAME.equals(layoutData.ˏ()) && layoutData.ˋ().size() != 0) {
                    ˊ((ForumCommentDetailHeadCardBean) layoutData.ˋ().get(0));
                }
                if (ForumTitleSortCardBean.NAME.equals(layoutData.ˏ()) && layoutData.ˋ().size() != 0) {
                    ForumTitleSortCardBean forumTitleSortCardBean = (ForumTitleSortCardBean) layoutData.ˋ().get(0);
                    this.ᐝˋ = forumTitleSortCardBean.ᐝ();
                    this.ꜟ = forumTitleSortCardBean.ʽ();
                    this.ॱʻ = ˋ(this.ᐝˋ);
                }
                if ("forumreplycard".equals(layoutData.ˏ()) && layoutData.ˋ().size() != 0) {
                    ॱ(layoutData.ˋ());
                    this.ꜞ = ˏ(layoutData.ˋ());
                    this.ﾞ = ˊ(layoutData.ˋ());
                    this.ᐧ = layoutData.ˋ().size();
                }
            }
        }
    }

    private void ˊ(JGWTabDetailResponse jGWTabDetailResponse) {
        List<LayoutData> ᐝॱ = jGWTabDetailResponse.ᐝॱ();
        if (ᐝॱ != null && ᐝॱ.size() > 0) {
            for (LayoutData layoutData : ᐝॱ) {
                if (ForumCommentDetailHeadCardBean.NAME.equals(layoutData.ˏ()) && layoutData.ˋ().size() != 0) {
                    ˊ((ForumCommentDetailHeadCardBean) layoutData.ˋ().get(0));
                    return;
                }
            }
        }
    }

    private void ˊ(ForumCommentDetailHeadCardBean forumCommentDetailHeadCardBean) {
        this.ˉ = forumCommentDetailHeadCardBean;
        this.ˌ = forumCommentDetailHeadCardBean.ˋॱ();
        this.ˋᐝ = forumCommentDetailHeadCardBean.ˏॱ();
        this.ˍ = forumCommentDetailHeadCardBean.ʼ().ˏ();
        this.ˊᐝ = forumCommentDetailHeadCardBean.ʼ().ˊॱ();
        this.ˎˎ = forumCommentDetailHeadCardBean.ʽ().ʼ();
        this.ᐨ = forumCommentDetailHeadCardBean.ʼ().ॱˊ();
        this.ॱʼ = forumCommentDetailHeadCardBean.ॱˊ();
        this.ॱʽ = forumCommentDetailHeadCardBean.ʼ().ʻ();
        this.ʻᐝ = forumCommentDetailHeadCardBean.ˊ();
        this.ʼˊ = forumCommentDetailHeadCardBean.ॱˎ();
        this.ʻˊ = forumCommentDetailHeadCardBean.ʻॱ();
        this.ॱʻ = forumCommentDetailHeadCardBean.ͺ();
    }

    public void ˎ(TaskFragment taskFragment, List<cvt> list) {
    }

    private void ˊᐝ() {
        this.ᐝᐝ.setVisibility(0);
        this.ॱˎ.setText(getString(j.ʽ, new Object[]{Integer.valueOf(this.ˊᐝ)}));
        this.ʻॱ.setVisibility(0);
        ˊˊ();
        if (this.ˎˏ == 1) {
            this.ᐝॱ.setVisibility(8);
        } else if (this.ˎˏ == 2) {
            this.ᐝॱ.setVisibility(0);
        }
        if (!TextUtils.isEmpty(this.ˌ)) {
            this.ʿ.setText(this.ˌ);
        }
        if (this.ᐝˊ) {
            ᐝ();
        }
        if (this.ꓸ != 0 && this.ﾞ != -1 && this.ﹳ) {
            if (this.ﾞ == 0) {
                this.ͺ.ˊॱ(this.ﾞ + 1);
            } else {
                this.ͺ.ˊॱ(this.ﾞ);
            }
            this.ͺ.W_();
        }
    }

    private void ˊˊ() {
        this.ˋˋ = new PopupMenu(this, this.ʻॱ);
        getMenuInflater().inflate(h.ˊ, this.ˋˋ.getMenu());
        if (UserSession.getInstance().isLoginSuccessful() && this.ˎˎ) {
            this.ˋˋ.getMenu().findItem(o.bue.e.ˊˊ).setVisible(false);
            this.ˋˋ.getMenu().findItem(o.bue.e.ʽ).setVisible(true);
            this.ˋˋ.getMenu().findItem(o.bue.e.ʼॱ).setVisible(true);
        } else {
            this.ˋˋ.getMenu().findItem(o.bue.e.ˊˊ).setVisible(true);
            this.ˋˋ.getMenu().findItem(o.bue.e.ʽ).setVisible(false);
            this.ˋˋ.getMenu().findItem(o.bue.e.ʼॱ).setVisible(false);
        }
        this.ˋˋ.setOnMenuItemClickListener(new OnMenuItemClickListener(this) {
            final /* synthetic */ CommentDetailActivity ˊ;

            {
                this.ˊ = r1;
            }

            public boolean onMenuItemClick(MenuItem menuItem) {
                boolean z = true;
                int itemId = menuItem.getItemId();
                if (itemId == o.bue.e.ʼॱ) {
                    this.ˊ.ˉ();
                } else if (itemId == o.bue.e.ʽ) {
                    this.ˊ.ˍ();
                } else if (itemId == o.bue.e.ˊˊ) {
                    this.ˊ.ˎˎ();
                } else {
                    z = false;
                }
                if (z) {
                    this.ˊ.ˋˋ.dismiss();
                }
                return false;
            }
        });
    }

    private int ˊ(List<JsonBean> list) {
        if (CollectCheck.isEmpty((List) list) || this.ꓸ == 0) {
            return -1;
        }
        int i = 0;
        while (i < list.size()) {
            if (((ForumReplyCardBean) list.get(i)).ˊ().ˊ() == this.ꓸ) {
                break;
            }
            i++;
        }
        i = -1;
        return i;
    }

    private void ˉ() {
        if (bsd.ˏ(this.ˋॱ)) {
            evk.ˏ(this, j.ॱ, 0).ˋ();
        } else if (btb.ˊ(this, this.ᐨ, true)) {
            ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(this, 15).ˏ(new fjq<Boolean>(this) {
                final /* synthetic */ CommentDetailActivity ˊ;

                {
                    this.ˊ = r1;
                }

                public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                    if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                        this.ˊ.ˊˋ();
                    }
                }
            });
        }
    }

    private void ˊˋ() {
        fjb ˎ = fho.ˏ().ˋ("Option").ˎ("option.update.comment");
        IUpdateCommentActivityProtocol iUpdateCommentActivityProtocol = (IUpdateCommentActivityProtocol) ˎ.ˊ();
        iUpdateCommentActivityProtocol.setDomainId(this.ˊॱ);
        byg o_byg = new byg(this.ˉ.ˊॱ(), this.ˉ.ʼ().ॱ(), ˋˊ());
        o_byg.ॱ(this.ˉ.ʼ().ˏ());
        iUpdateCommentActivityProtocol.setCommentData(o_byg);
        fiu.ˊ().ॱ((Context) this, ˎ, new fjc<IUpdateCommentActivityResult>(this) {
            final /* synthetic */ CommentDetailActivity ˎ;

            {
                this.ˎ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ॱ(i, (IUpdateCommentActivityResult) obj);
            }

            public void ॱ(int i, IUpdateCommentActivityResult iUpdateCommentActivityResult) {
                ((CommentDetailActivity) ˊ()).ˏ(i, iUpdateCommentActivityResult);
            }
        });
    }

    private void ˏ(int i, IUpdateCommentActivityResult iUpdateCommentActivityResult) {
        bqx.ˏ("CommentDetailActivity", "modify comment result:" + i);
        if (i == -1) {
            evk.ˏ(getString(j.ˎ));
            ˎ(0);
        }
    }

    private byl ˋˊ() {
        if (this.ˉ == null || this.ˉ.ʼ() == null || CollectCheck.isEmpty(this.ˉ.ʼ().ॱॱ())) {
            return null;
        }
        ImageInfo imageInfo = (ImageInfo) this.ˉ.ʼ().ॱॱ().get(0);
        return new byl(imageInfo.ॱ(), imageInfo.ˊ());
    }

    private void ˍ() {
        this.ॱˊ.ˏ(this, this.ˍ, this.ˊॱ).ˏ(new fjq<Boolean>(this) {
            final /* synthetic */ CommentDetailActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                    this.ˊ.ـ = true;
                    Intent intent = new Intent("com.huawei.appgallery.forum.posts.deletecomment");
                    intent.putExtra("comment_id", this.ˊ.ˍ);
                    ll.ˏ(this.ˊ).ˋ(intent);
                    this.ˊ.finish();
                }
            }
        });
    }

    private void ˎˎ() {
        if (btb.ˊ(this, this.ᐨ, false)) {
            List arrayList = new ArrayList();
            if (!(this.ˉ.ʼ().ॱॱ() == null || this.ˉ.ʼ().ॱॱ().size() == 0)) {
                arrayList.addAll(this.ˉ.ʼ().ॱॱ());
            }
            ((bwx) fho.ˏ().ˋ("Operation").ॱ(bwx.class)).ˎ(this, new d(this.ˉ.ʽ().ˎ(), this.ˉ.ʽ().ˋ(), 1, this.ˍ).ॱ(arrayList).ˎ(this.ˉ.ʼ().ॱ()).ˏ(this.ˊॱ).ˎ());
        }
    }

    private void ˋᐝ() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        azb.ˏ(findViewById(o.bue.e.ˏˎ));
        this.ﾟ = (RelativeLayout) findViewById(o.bue.e.ˋᐝ);
        this.ॱˎ = (TextView) findViewById(o.bue.e.ͺॱ);
        this.ॱˎ.setText(getString(j.ᐝ));
        findViewById(o.bue.e.ˎ).setOnClickListener(this);
        this.ʻॱ = findViewById(o.bue.e.ᐝॱ);
        this.ʻॱ.setVisibility(8);
        this.ʻॱ.setOnClickListener(this);
    }

    public void onClick(View view) {
        if (view.getId() == o.bue.e.ˎ) {
            onBackPressed();
        } else if (view.getId() == o.bue.e.ᐝॱ) {
            this.ˋˋ.show();
        } else if (view.getId() == o.bue.e.ˌ) {
            ˌ();
        } else if (view.getId() == o.bue.e.ˋˊ) {
            ᐝˊ();
            if (!doo.ˊ((Context) this)) {
                evk.ˏ(this, j.ˋॱ, 0).ˋ();
            } else if (!this.ˋˊ) {
                ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(this, 15).ˏ(new fjq<Boolean>(this) {
                    final /* synthetic */ CommentDetailActivity ॱ;

                    {
                        this.ॱ = r1;
                    }

                    public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                        if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                            this.ॱ.ͺॱ();
                        }
                    }
                });
            }
        }
    }

    private void ˌ() {
        if (!TextUtils.isEmpty(this.ˋᐝ)) {
            fjb ˎ = fho.ˏ().ˋ("Posts").ˎ("post.detail.activity");
            IPostDetailProtocol iPostDetailProtocol = (IPostDetailProtocol) ˎ.ˊ();
            iPostDetailProtocol.setUri(this.ˋᐝ);
            iPostDetailProtocol.setDomainId(this.ˊॱ);
            fiu.ˊ().ˏ(this, ˎ);
        }
    }

    public void ᐝ() {
        if (btb.ˊ(this, this.ᐨ, false)) {
            ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(this, 15).ˏ(new fjq<Boolean>(this) {
                final /* synthetic */ CommentDetailActivity ˋ;

                {
                    this.ˋ = r1;
                }

                public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                    if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                        this.ˋ.ˈ.setFocusable(true);
                        this.ˋ.ˈ.setFocusableInTouchMode(true);
                        this.ˋ.ˈ.requestFocus();
                        this.ˋ.ˋˋ();
                    }
                }
            });
        }
    }

    private void ˋˋ() {
        new Handler().postDelayed(new Runnable(this) {
            final /* synthetic */ CommentDetailActivity ˋ;

            {
                this.ˋ = r1;
            }

            public void run() {
                InputMethodManager inputMethodManager = (InputMethodManager) this.ˋ.getSystemService("input_method");
                if (inputMethodManager != null) {
                    inputMethodManager.showSoftInput(this.ˋ.ˈ, 0);
                }
            }
        }, 50);
    }

    private void ˏˏ() {
        this.ˈ.setText("");
        this.ˈ.setHint(j.ˋ);
        this.ˏˎ = null;
        this.ˈ.clearFocus();
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService("input_method");
        if (this.ˈ != null && inputMethodManager != null && inputMethodManager.isActive()) {
            inputMethodManager.hideSoftInputFromWindow(this.ˈ.getApplicationWindowToken(), 2);
        }
    }

    private void ˋ(Editable editable) {
        if (editable.length() <= 0 || editable.toString().trim().isEmpty()) {
            this.ʾ.setClickable(false);
            this.ʽॱ.setImageResource(bue.d.ˊ);
            return;
        }
        this.ʾ.setClickable(true);
        this.ʽॱ.setImageResource(bue.d.ʼ);
    }

    public void ˏ(User user) {
        if (user == null) {
            this.ˏˎ = null;
            this.ˈ.setHint(getString(j.ˋ));
            return;
        }
        this.ˏˎ = user;
        this.ˈ.setHint(getResources().getString(j.ॱˊ) + this.ˏˎ.ˋ());
    }

    private String ˎˏ() {
        String obj = this.ˈ.getText().toString();
        if (obj.trim().isEmpty()) {
            return null;
        }
        return obj.replaceAll("[\\t\\n\\r]", "[br]");
    }

    private void ͺॱ() {
        if (this.ˍ == 0) {
            ˏˏ();
        } else if (!TextUtils.isEmpty(ˎˏ())) {
            Object ˊ;
            ॱʼ();
            brf o_brf = (brf) fho.ˏ().ˋ("Base").ॱ(brf.class);
            if (this.ˏˎ == null || this.ˏˎ.ॱ() == null) {
                o_brf.ॱ(byt.METHOD, ReplyResponse.class);
                ˊ = new byt.b(this.ˍ, ˎˏ()).ˊ(null).ˏ(bsv.ॱ(this.ˊॱ)).ˊ();
            } else {
                o_brf.ॱ(byt.METHOD, ReplyResponse.class);
                byw ˎ = new byw.a(this.ˍ, this.ˏˎ.ॱ(), ˎˏ()).ॱ(null).ˊ(bsv.ॱ(this.ˊॱ)).ˎ();
            }
            ((brc) fho.ˏ().ˋ("Base").ॱ(brc.class)).ˋ(ˊ, new o.brc.e<brj, ReplyResponse>(this) {
                final /* synthetic */ CommentDetailActivity ˏ;

                {
                    this.ˏ = r1;
                }

                public /* synthetic */ void ˋ(Object obj, Object obj2) {
                    ॱ((brj) obj, (ReplyResponse) obj2);
                }

                public /* synthetic */ void ˏ(Object obj, Object obj2) {
                    ˋ((brj) obj, (ReplyResponse) obj2);
                }

                public void ˋ(brj o_brj, ReplyResponse replyResponse) {
                }

                public void ॱ(brj o_brj, ReplyResponse replyResponse) {
                    if (replyResponse.getResponseCode() == 0 && replyResponse.getRtnCode_() == 0) {
                        evk.ˏ(this.ˏ.getString(byc.j.ˊ));
                        this.ˏ.ॱ(replyResponse.ˋ());
                        this.ˏ.ˏˏ();
                        this.ˏ.ॱͺ();
                        brd.ॱ.ˎ(bqy.ˋ().ˎ(this.ˏ), this.ˏ.ˊॱ, String.valueOf(this.ˏ.ʻᐝ), String.valueOf(this.ˏ.ˍ), String.valueOf(replyResponse.ˋ()));
                    } else if (replyResponse.getRtnCode_() == 3004) {
                        evk.ˏ(this.ˏ.getString(bse.ˏ.ˏ("reply", 3004)));
                        this.ˏ.ॱͺ();
                    } else {
                        evk.ˏ(this.ˏ.getString(bse.ˏ.ॱ(replyResponse.getRtnCode_()).ˏ()));
                        this.ˏ.ॱͺ();
                    }
                }
            });
        }
    }

    private void ॱ(long j) {
        bul ॱʾ = this.ͺ.ॱʾ();
        if (ॱʾ != null) {
            ॱʾ.ˋ(ˊ(j));
            ॱʾ.ͺ();
            this.ͺ.ˊॱ(1);
            this.ͺ.W_();
        }
        ॱʻ();
    }

    private ForumReplyCardBean ˊ(long j) {
        ForumReplyCardBean forumReplyCardBean = new ForumReplyCardBean();
        forumReplyCardBean.ˎ(this.ˊॱ);
        Reply reply = new Reply();
        reply.ˎ(ˎˏ());
        PostTime postTime = new PostTime();
        postTime.ॱ(String.valueOf(System.currentTimeMillis()));
        postTime.ˊ(String.valueOf(System.currentTimeMillis()));
        reply.ˏ(postTime);
        reply.ˋ(j);
        User user = new User();
        UserSession instance = UserSession.getInstance();
        user.ॱ(instance.getUserId());
        if (TextUtils.isEmpty(instance.getNickname())) {
            user.ˎ(instance.getUserName());
        } else {
            user.ˎ(instance.getNickname());
        }
        user.ˋ(instance.getHeadUrl());
        user.ॱ(1);
        user.ˏ(this.ʼˊ);
        user.ˋ(this.ʻˊ);
        cbc ˊ = ((cbd) fho.ˏ().ˋ("User").ॱ(cbd.class)).ˊ();
        if (ˊ != null) {
            user.ˊ(ˊ.ˎ());
            user.ˏ(ˊ.ˏ());
        }
        reply.ˋ(user);
        if (this.ˏˎ != null) {
            reply.ˎ(this.ˏˎ);
        }
        forumReplyCardBean.ॱ(reply);
        return forumReplyCardBean;
    }

    public void ˎ(long j) {
        this.ﹳ = false;
        this.ㆍ = false;
        this.ᐝˊ = false;
        this.ͺ.ʽ(ˋ(j));
        this.ͺ.ˊॱ(1);
        this.ͺ.ˎͺ();
    }

    public void ॱˊ() {
        this.ﹳ = false;
        this.ㆍ = false;
        ˏˎ();
        this.ᐝˊ = false;
        this.ͺ.ʽ(this.ॱˋ);
        this.ͺ.ˎͺ();
    }

    private void ˏ(long j) {
        bul ॱʾ = this.ͺ.ॱʾ();
        ॱʾ.ˏ(j);
        ॱʾ.ͺ();
    }

    private void ˏˎ() {
        if (!TextUtils.isEmpty(this.ॱˋ)) {
            if (this.ॱˋ.contains("cid_")) {
                String[] split = this.ॱˋ.split(",");
                if (split.length != 0) {
                    this.ॱˋ = split[0];
                }
            }
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append(this.ॱˋ);
            if (ˎ() == 1) {
                stringBuffer.append(",sort_0");
            } else if (ˎ() == 0) {
                stringBuffer.append(",sort_1");
            }
            this.ॱˋ = stringBuffer.toString();
        }
    }

    private void ˑ() {
        if (!TextUtils.isEmpty(this.ॱˋ) && !this.ॱˋ.contains("sort_")) {
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append(this.ॱˋ);
            if (ˎ() == 1) {
                stringBuffer.append(",sort_0");
            } else if (ˎ() == 0) {
                stringBuffer.append(",sort_1");
            }
            this.ॱˋ = stringBuffer.toString();
        }
    }

    private String ˋ(long j) {
        if (TextUtils.isEmpty(this.ॱˋ)) {
            return null;
        }
        if (this.ॱˋ.contains("sort_") || this.ॱˋ.contains("cid_")) {
            String[] split = this.ॱˋ.split(",");
            if (split.length != 0) {
                this.ॱˋ = split[0];
            }
        }
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(this.ॱˋ);
        if (ˎ() == 1) {
            stringBuffer.append(",sort_0");
        } else if (ˎ() == 0) {
            stringBuffer.append(",sort_1");
        }
        if (j != 0) {
            stringBuffer.append(",cid_").append(String.valueOf(j));
        }
        return stringBuffer.toString();
    }

    private void ـ() {
        if (!TextUtils.isEmpty(this.ॱˋ) && this.ॱˋ.contains("cid_")) {
            String[] split = this.ॱˋ.split(",");
            if (split.length != 0) {
                Object obj = null;
                for (String str : split) {
                    if (str.contains("cid_")) {
                        obj = str.substring(4);
                    }
                }
                if (!TextUtils.isEmpty(obj)) {
                    this.ꓸ = Long.parseLong(obj);
                }
            }
        }
    }

    private void ॱ(List<JsonBean> list) {
        if (!CollectCheck.isEmpty((List) list) && this.ꓸ != 0) {
            for (JsonBean jsonBean : list) {
                ForumReplyCardBean forumReplyCardBean = (ForumReplyCardBean) jsonBean;
                if (forumReplyCardBean.ˊ().ˊ() == this.ꓸ) {
                    this.ˏˎ = forumReplyCardBean.ˊ().ॱ();
                }
            }
            if (this.ˏˎ != null) {
                ˏ(this.ˏˎ);
            }
        }
    }

    private void ॱ(User user) {
        if (btb.ˊ(this, this.ᐨ, false)) {
            ˏ(user);
            ᐝ();
        }
    }

    public int P_() {
        return this.ˎˏ;
    }

    public String ˊ() {
        return this.ᐝˋ;
    }

    public int Q_() {
        return this.ᐧ;
    }

    public boolean R_() {
        return this.ˎˎ;
    }

    public long ʻ() {
        return this.ꓸ;
    }

    public int ॱॱ() {
        if (this.ꜞ) {
            return 1;
        }
        return 0;
    }

    public void ˏ(int i) {
        this.ͺॱ = i;
    }

    public int ˎ() {
        return this.ͺॱ;
    }

    public void onStart() {
        super.onStart();
        ll.ˏ(this).ˏ(this.ˏˏ, this.ˑ);
    }

    public void onStop() {
        super.onStop();
        ll.ˏ(this).ˋ(this.ˏˏ);
    }

    public void finish() {
        if (!this.ـ && (this.ॱͺ || this.ᶥ)) {
            ॱʽ();
        }
        super.finish();
    }

    private void ॱʽ() {
        fjf ˊ = fjf.ˊ(this);
        ICommentDetailResult iCommentDetailResult = (ICommentDetailResult) ˊ.ॱ();
        iCommentDetailResult.setLike(this.ॱʼ);
        iCommentDetailResult.setLikeCount(this.ॱʽ);
        iCommentDetailResult.setReplyCount(this.ॱʻ);
        setResult(-1, ˊ.ˊ());
    }

    private void ॱʼ() {
        this.ˋˊ = true;
        this.ˊˋ.setVisibility(0);
        this.ʽॱ.setVisibility(8);
    }

    private void ॱͺ() {
        this.ˋˊ = false;
        this.ˊˋ.setVisibility(8);
        this.ʽॱ.setVisibility(0);
    }

    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            View currentFocus = getCurrentFocus();
            if (ˎ(motionEvent)) {
                return super.dispatchTouchEvent(motionEvent);
            }
            if (ॱ(currentFocus, motionEvent) && ˊ((Context) this, currentFocus) && !this.ʾ.isClickable()) {
                return true;
            }
        }
        return super.dispatchTouchEvent(motionEvent);
    }

    private boolean ˎ(MotionEvent motionEvent) {
        Rect rect = new Rect();
        this.ʾ.getGlobalVisibleRect(rect);
        if (motionEvent.getX() < ((float) rect.left) || motionEvent.getX() > ((float) rect.right) || motionEvent.getY() > ((float) rect.bottom) || motionEvent.getY() < ((float) rect.top)) {
            return false;
        }
        return true;
    }

    private boolean ॱ(View view, MotionEvent motionEvent) {
        if (!(view instanceof EditText)) {
            return false;
        }
        int[] iArr = new int[]{0, 0};
        view.getLocationInWindow(iArr);
        int i = iArr[0];
        int i2 = iArr[1];
        int height = view.getHeight() + i2;
        int width = view.getWidth() + i;
        if (motionEvent.getX() <= ((float) i) || motionEvent.getX() >= ((float) width) || motionEvent.getY() <= ((float) i2) || motionEvent.getY() >= ((float) height)) {
            return true;
        }
        return false;
    }

    private boolean ˊ(Context context, View view) {
        this.ˈ.clearFocus();
        InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService("input_method");
        if (inputMethodManager != null) {
            return inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
        return false;
    }

    private void ॱʻ() {
        this.ॱʻ++;
        this.ᶥ = true;
    }

    private int ˋ(String str) {
        String trim = str.trim();
        if (TextUtils.isEmpty(trim)) {
            return 0;
        }
        StringBuffer stringBuffer = new StringBuffer();
        int i = 0;
        while (i < trim.length()) {
            if (trim.charAt(i) >= '0' && trim.charAt(i) <= '9') {
                stringBuffer.append(trim.charAt(i));
            }
            i++;
        }
        Object stringBuffer2 = stringBuffer.toString();
        if (TextUtils.isEmpty(stringBuffer2)) {
            return 0;
        }
        return bsv.ॱ(stringBuffer2, 0);
    }

    private boolean ˏ(List<JsonBean> list) {
        if (this.ꓸ == 0 || this.ꜟ == 0 || CollectCheck.isEmpty((List) list)) {
            return false;
        }
        return ((ForumReplyCardBean) list.get(0)).ˊ().ˊ() == this.ꓸ;
    }

    private int ᐝˋ() {
        int ॱ = ((epv.ॱ(this) - ˊ((Context) this)) - this.ﾟ.getHeight()) - (((int) getResources().getDimension(c.ˎ)) * 2);
        if (azb.ˎ((Context) this)) {
            return ॱ - this.ꞌ;
        }
        return ॱ - this.ʹ;
    }

    private int ˊ(Context context) {
        int identifier = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (identifier > 0) {
            return context.getResources().getDimensionPixelSize(identifier);
        }
        return 0;
    }

    public void onConfigurationChanged(Configuration configuration) {
        ᐝˊ();
        this.ˈ.setMaxHeight(ᐝˋ());
        super.onConfigurationChanged(configuration);
    }

    private void ᐝˊ() {
        if (this.ˈ != null) {
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService("input_method");
            if (inputMethodManager != null && inputMethodManager.isActive()) {
                inputMethodManager.hideSoftInputFromWindow(this.ˈ.getApplicationWindowToken(), 2);
            }
        }
    }
}
